#ifndef _EDITOR_SCREEN_H_
# define _EDITOR_SCREEN_H_

# include <SDL/SDL.h>
# include <vector>
# include "Utils\\IScreen.h"
# include "Utils\\Surface.h"
# include "Utils\\Rect.h"
# include "Utils\\ScreenManager.h"
# include "Elements\\Image.h"
# include "Bloc.h"
# include "BlocManager.h"

struct EditorArgs : public SDL::UTILS::ScreenArgs
{
public:
	SDL::UTILS::Surface& LoadedBackground;
	Bloc*& CurrentBloc;
	BlocManager& Blocs;
	bool& ShowGrid;

public:
	EditorArgs(SDL_Surface* _screen, SDL_Event* _event,
			   SDL::UTILS::Surface& _loadedBackground,
			   Bloc*& _currentBloc, BlocManager& _blocs, bool& _showGrid);
	virtual ~EditorArgs();
};

class EditorScreen : public SDL::UTILS::IScreen
{
private:
	SDL::UTILS::Surface m_grid;
	SDL::UTILS::Surface m_surface;
	SDL::UTILS::Rect m_position;
	SDL::UTILS::Rect m_gridLimits;
	SDL_Rect m_cursorPosition;
	SDL::ELEMENTS::Image m_cursor;

public:
	EditorScreen();
	virtual ~EditorScreen();

	virtual void Draw(SDL::UTILS::IArgs* _datas);
	virtual void Exec(SDL::UTILS::IArgs* _datas);
	static bool Manage(SDL::UTILS::ScreenManager::Element* _caller,
					   SDL::UTILS::IArgs* _args);

private:
	void InitGrid();
	void MouseEvents(Uint8 _button, int _x, int _y, EditorArgs* _args);
	void LeftButton(EditorArgs* _args, SDL_Rect& _r);
	void RightButton(EditorArgs* _args, SDL_Rect& _r);
	void MiddleButton(EditorArgs* _args, SDL_Rect& _r);
	void WheelMove(EditorArgs* _args);
	void DrawCursor(EditorArgs* _args);
};

#endif // _EDITOR_SCREEN_H_
